﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using WAU.Models.Framework;

namespace WAU.Test
{
    /// <summary>
    /// 测试实用工具类
    /// </summary>
    public class TestUtils
    {
        /// <summary>
        /// 测试资源文件夹
        /// </summary>
        public static string TEST_RESOURCE_DIR = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestResources");

        /// <summary>
        /// static ctor
        /// </summary>
        static TestUtils() 
        {
            using (FileStream fs = new FileStream(
                                        Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json"), 
                                        FileMode.Open))
            using (StreamReader sr = new StreamReader(fs))
            {
                string configJson = sr.ReadToEnd();
                GlobalConfig.Setting = JsonSerializer.Deserialize<GlobalConfig>(configJson);
            }
        }

        /// <summary>
        /// 只是为了执行静态方法，赋值 GlobalConfig
        /// </summary>
        public static void Init() { }
    }
}
